% Libraries
\usepackage{titlesec} 
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{colortbl}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage{subfigure}
\usepackage{layouts}
\usepackage{graphicx}
\usepackage[yyyymmdd,hhmmss]{datetime}
\usepackage{hyperref}
\usepackage{helvet}

%------------------Color Set--------------------------
\definecolor{LightBlue}{RGB}{66, 163, 251}
\definecolor{DarkBlue}{RGB}{36, 100, 176}
\definecolor{LightGray}{gray}{.94}
\definecolor{DarkGray}{gray}{.172}
\definecolor{Orange}{RGB}{229, 133, 3}
\definecolor{MediumBlue}{RGB}{38, 119, 193}

%------------------Section Default Setting-------------
\titleformat*{\section}{\color{DarkBlue}\normalfont\bfseries\Huge}
\titleformat*{\subsection}{\color{LightBlue}\normalfont\bfseries\LARGE}
\titleformat*{\subsubsection}{\color{MediumBlue}\normalfont\bfseries\LARGE}

%-------------------Section Numbers Removal------------
\setcounter{secnumdepth}{0}

%-------------------Set New Default Font------------
\renewcommand\familydefault{\sfdefault}

%-------------------------Header & Footer------------------------
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}

% Header
\fancyhead[L]{\ifthenelse{\value{page}=1}{ }{pyHRV Report}}
\fancyhead[R]{\ifthenelse{\value{page}=1}{ }{\subject, \gender, \age, \today\, \currenttime}}

% Footer
\lfoot{HRV results \& report generated with pyHRV (v.\version)\\\url{https://github.com/PGomes92/pyhrv}}
\rfoot{\thepage\ of \pageref{page:lastpage}}

%-------------------------Custom Table Functions------------------------
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\newcommand{\btcell}[1]{{\cellcolor{LightBlue}\textbf{#1}}}
\newcommand{\bcell}[1]{{\cellcolor{LightBlue}{#1}}}
\newcommand{\gcell}[1]{{\cellcolor{LightGray}{#1}}}

\newcommand{\dline}{\hline\hline}

%-------------------------Define new boolean variables to toggle section visibility------------------------
\newif\ifecgsignal
\newif\iftachogram
\newif\ifhistogram
\newif\ifhrheatplot
\newif\iftdomain
\newif\ifwelch
\newif\ifar
\newif\iflomb
\newif\iffdomain
\newif\ifndomain
\newif\ifpoincare
\newif\ifdfa
\newif\ifsampen